<script type="text/javascript">
    window.onload = function() {
        var spans = document.getElementsByTagName("span");
        try {
            var span2 = spans("span2");
            document.getElementById("info").innerHTML = "NodeList(name).id: " + span2.id;
        } catch(err) {
            document.getElementById("info").innerHTML = "NodeList(name): " + err;
        }
    }
</script>
<span id="span1"></span>
<span id="span2"></span>

<div id="info"></div>